;;;QQ:67762207
[@NPCSetDairyQuest]
{
#IF
Check [209] 1
Check [409] 0
#ACT
FormatStr "FLD_USERNAME='%s'" %USERNAME
ReadValueSql "TBL_DairyQuestUser" %A9 "FLD_QuestIdx,FLD_Status,FLD_TQNPC" [@NPCSetDairyQuest_Set]
#SAY
Ժ \\
#ELSESAY
<%UESERNAME>ûʲô˵ġ \\
< /@exit>

[@NPCSetDairyQuest_Set()]
#ACT
mov D0 %ARG(1)
mov A0 %ARG(2)
Mov A1 %ARG(3)

#IF
!StartDailyQuest
Equal A0 "Ready"
Equal A1 %NPCNAME
#ACT
goto @NPCSetDairyQuest_Ready
break

#IF
!StartDailyQuest
Equal A0 "Act"
#ACT
goto @NPCSetDairyQuest_Act
break

#IF
#SAY
ûʲôͷ \\
< /@exit>

[@NPCSetDairyQuest_Ready]
#ACT
goto @NPCSet_QuestDairyToday

[@NPCSetDairyQuest_Act]
#ACT
goto @NPCACT_QuestDairyToday




[@NPCSet_QuestDairyToday]
#IF
!StartDailyQuest
Check [209] 1
Check [409] 0
#ACT
FormatStr "FLD_USERNAME='%s'" %USERNAME
ReadValueSql "TBL_DairyQuestUser" %A9 "FLD_QuestIdx,FLD_TQCASE" [@NPCSet_QuestDairyToday_Next]
#SAY
Ժ\\

[@NPCSet_QuestDairyToday_Next()]
#ACT
mov D0 %ARG(1)	;;FLD_QuestIdx
mov D1 %ARG(2)	;;FLD_TQCASE
FormatStr "FLD_TQIDX=%s" %D0
ReadStringSql "TBL_DairyQuestSet" %A9 "FLD_TQNPCContent1" [@NPCSet_QuestDairyToday_Next1]

[@NPCSet_QuestDairyToday_Next1]
#ACT
mov A0 %ARG(1)	;;FLD_TQNPCContent1-Npc˵Ļ

#IF
Equal D1 10
#ACT
close
Set [210] 0
Set [409] 1
goto @NPCACT_QuestDairyToday_Result
break

#IF
#SAY
<$OUTPUT(A0)> \
</@NPCSet_QuestDairyToday_Next3> \
<ܾ/@exit>

[@NPCSet_QuestDairyToday_Next3]
#IF
Equal D1 0
#ACT
close
FormatStr "FLD_USERNAME='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='Act',FLD_Step=''"
goto @ConfirmTodayQuestEx
break

#IF
Equal D1 1
#ACT
close
Set [210] 1
FormatStr "FLD_USERNAME='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='Act',FLD_Step='Progress',FLD_STEP1='',FLD_STEP2='',FLD_STEP3=''"
goto @ConfirmTodayQuestEx
break

#IF
Equal D1 2
#ACT
close
Set [210] 1
FormatStr "FLD_USERNAME='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='Act',FLD_Step='Progress'"
goto @ConfirmTodayQuestEx
break

#IF
Equal D1 3
#ACT
close
FormatStr "FLD_USERNAME='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='Act',FLD_Step=''"
goto @ConfirmTodayQuestEx
break

#IF
Equal D1 4
#ACT
close
FormatStr "FLD_USERNAME='%s'" %USERNAME
ReadValueSQL "TBL_DairyQuestUser" %A9 "FLD_Condition2,FLD_Condition2Amount" @NPCSet_QuestDairyToday_Next3_Case4or7
break

#IF
Equal D1 7
#ACT
close
FormatStr "FLD_USERNAME='%s'" %USERNAME
ReadValueSQL "TBL_DairyQuestUser" %A9 "FLD_Condition2,FLD_Condition2Amount" @NPCSet_QuestDairyToday_Next3_Case4or7
break

#IF
Equal D1 9
#ACT
close
Set [210] 1
FormatStr "FLD_USERNAME='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='Act',FLD_Step='Progress',FLD_STEP1='',FLD_STEP2='',FLD_STEP3=''"
goto @ConfirmTodayQuestEx
break

#IF
#ACT
close
FormatStr "FLD_USERNAME='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='Act',FLD_Step='Progress'"
goto @ConfirmTodayQuestEx
break

[@NPCSet_QuestDairyToday_Next3_Case4or7()]
#ACT
Mov A0 %ARG(1)
Mov D0 %ARG(2)
Give %A0 %D0
FormatStr "FLD_USERNAME='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='Act',FLD_Step='Progress'"
goto @ConfirmTodayQuestEx
break

[@ConfirmTodayQuestEx]
#SAY
Ժ\\
#ACT
FormatStr "FLD_UserName='%s'" %USERNAME
ReadValueSql "TBL_DairyQuestUser" %A9 "FLD_QuestIdx,FLD_Status" [@PRECall_SetDairyQuest_Check]

[@PRECall_SetDairyQuest_Check()]
#IF
#ACT
mov D8 %ARG(1)
mov A0 %ARG(2)

#IF
ELARGE D8 136
ESMALL D8 200 
#ACT
FormatStr "FLD_UserName='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='End'"
break
#SAY
û¿ˣ\\
<ر/@exit>

#IF
ELARGE D8 266
ESMALL D8 300 
#ACT
FormatStr "FLD_UserName='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='End'"
break
#SAY
û¿ˣ\\
<ر/@exit>

#IF
ELARGE D8 600
ESMALL D8 699
#ACT
FormatStr "FLD_UserName='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='End'"
break
#SAY
û¿ˣ\\
<ر/@exit>

#IF
ELARGE D8 703
ESMALL D8 899 
#ACT
FormatStr "FLD_UserName='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='End'"
break
#SAY
û¿ˣ\\
<ر/@exit>

#IF
EQUAL D8 400
or EQUAL D8 500
or LARGE D8 900
#ACT
FormatStr "FLD_UserName='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='End'"
break
#SAY
û¿ˣ\\
<ر/@exit>


#IF
Equal A0 "Act"
#ACT
goto @Call_SetTodayQuest_ACT
break

#IF
Equal A0 "End"
#SAY
ûˡ\\
< /@exit>
#ACT
break

[@Call_SetTodayQuest_ACT]
#CALL [TodayQuest\HelperTodayBook.txt] @Act_QuestDairyToday


[@NPCACT_QuestDairyToday]
#IF
!StartDailyQuest
Check [209] 1
Check [409] 0
#ACT
FormatStr "FLD_USERNAME='%s'" %USERNAME
ReadValueSql "TBL_DairyQuestUser" %A9 "FLD_QuestIdx,FLD_Step,FLD_TQCASE,FLD_Condition1,FLD_Condition1Amount,FLD_Condition2" [@NPCACT_QuestDairyToday_Next]
#SAY
Ժ \\

[@NPCACT_QuestDairyToday_Next()]
#ACT
Mov D0 %ARG(1)	;;FLD_QuestIdx
Mov A0 %ARG(2)	;;FLD_Step
Mov D1 %ARG(3)	;;FLD_TQCASE
Mov A1 %ARG(4)	;;FLD_Condition1
Mov D2 %ARG(5)	;;FLD_Condition1Amount
Mov A2 %ARG(6)	;;FLD_Condition2
ReadValueSql "TBL_DairyQuestUser" %A9 "FLD_Condition2Amount,FLD_Condition3,FLD_Condition3Amount,FLD_TQNPC" [@NPCACT_QuestDairyToday_Next1]

[@NPCACT_QuestDairyToday_Next1()]
#ACT
Mov D3 %ARG(1)	;;FLD_Condition2Amount
Mov A3 %ARG(2)	;;FLD_Condition3
Mov D4 %ARG(3)	;;FLD_Condition3Amount
Mov A4 %ARG(4)	;;FLD_TQNPC

#IF
Equal A4 %NPCNAME
Equal D1 0
#ACT
Goto @NPCACT_QuestDairyToday_Case0
break

#IF
Equal A4 %NPCNAME
Equal D1 1
#ACT
goto @NPCACT_QuestDairyToday_Case1
break

#IF
Equal A4 %NPCNAME
Equal D1 2
#ACT
goto @NPCACT_QuestDairyToday_Case2
break

#IF
Equal A4 %NPCNAME
Equal D1 3
#ACT
goto @NPCACT_QuestDairyToday_Case3
break

#IF
Equal A4 %NPCNAME
Equal D1 4
#ACT
goto @NPCACT_QuestDairyToday_Case4_OriGinal
break

#IF
Equal A1 %NPCNAME
Equal D1 4
#ACT
goto @NPCACT_QuestDairyToday_Case4_New
break

#IF
Equal A4 %NPCNAME
Equal D1 5
#ACT
goto @NPCACT_QuestDairyToday_Case5_OriGinal
break

#IF
Equal A1 %NPCNAME
Equal D1 5
#ACT
goto @NPCACT_QuestDairyToday_Case5_New
break

#IF
Equal A4 %NPCNAME
Equal D1 6
#ACT
goto @NPCACT_QuestDairyToday_Case6_OriGinal
break

#IF
Equal A1 %NPCNAME
Equal D1 6
#ACT
goto @NPCACT_QuestDairyToday_Case6_New
break

#IF
Equal A4 %NPCNAME
Equal D1 7
#ACT
goto @NPCACT_QuestDairyToday_Case7_OriGinal
break

#IF
Equal A1 %NPCNAME
Equal D1 7
#ACT
goto @NPCACT_QuestDairyToday_Case7_New
break

#IF
Equal A4 %NPCNAME
Equal D1 8
#ACT
goto @NPCACT_QuestDairyToday_Case8_OriGinal
break

#IF
Equal A1 %NPCNAME
Equal D1 8
#ACT
goto @NPCACT_QuestDairyToday_Case8_New
break

#IF
Equal A4 %NPCNAME
Equal D1 9
#ACT
goto @NPCACT_QuestDairyToday_Case9
break

#IF
#SAY
˿ȥͦе\\
< /@exit>

[@NPCACT_QuestDairyToday_Case9]
#IF
Equal A0 "PreEnd"
#ACT
goto @NPCACT_QuestDairyToday_Result
#ELSEACT
goto @NPCACT_QuestDairyToday_ExceptSay

[@NPCACT_QuestDairyToday_Case8_OriGinal]
#IF
Equal A0 "PreEnd"
#ACT
goto @NPCACT_QuestDairyToday_Result
#ELSEACT
goto @NPCACT_QuestDairyToday_ExceptSay

[@NPCACT_QuestDairyToday_Case8_New]
#IF
!Equal A0 "PreEnd"
#ACT
goto @NPCACT_QuestDairyToday_NewSay
#ELSESAY
˺ﲻʲôæ\\
< /@exit>

[@NPCACT_QuestDairyToday_Case7_OriGinal]
#IF
Checkitem %A3 %D4
Equal A0 "PreEnd"
#ACT
Take %A3 %D4
goto @NPCACT_QuestDairyToday_Result
#ELSEACT
goto @NPCACT_QuestDairyToday_ExceptSay

[@NPCACT_QuestDairyToday_Case7_New]
#IF
!Checkitem %A2 %D3
#ACT
break
#SAY
Ȳ鿴һûµƷ \\
< /@exit>

#IF
Checkitem %A2 %D3
!Equal A0 "PreEnd"
#ACT
Take %A2 %D3
Give %A3 %D4
goto @NPCACT_QuestDairyToday_NewSay
#ELSESAY
˺ﲻʲôæ \\
< /@exit>

[@NPCACT_QuestDairyToday_Case6_OriGinal]
#IF
Equal A0 "PreEnd"
#ACT
goto @NPCACT_QuestDairyToday_Result
#ELSEACT
goto @NPCACT_QuestDairyToday_ExceptSay

[@NPCACT_QuestDairyToday_Case6_New]
#IF
!Equal A0 "PreEnd"
#ACT
goto @NPCACT_QuestDairyToday_NewSay
#ELSESAY
˺ﲻʲôæ\\
< /@exit>

[@NPCACT_QuestDairyToday_Case5_OriGinal]
#IF
Checkitem %A2 %D3
Equal A0 "PreEnd"
#ACT
Take %A2 %D3
goto @NPCACT_QuestDairyToday_Result
#ELSEACT
goto @NPCACT_QuestDairyToday_ExceptSay

[@NPCACT_QuestDairyToday_Case5_New]
#IF
!Equal A0 "PreEnd"
#ACT
Give %A2 %D3
goto @NPCACT_QuestDairyToday_NewSay
#ELSESAY
˺ﲻʲôæ\\
< /@exit>

[@NPCACT_QuestDairyToday_Case4_OriGinal]
#IF
Equal A0 "PreEnd"
#ACT
goto @NPCACT_QuestDairyToday_Result
#ELSEACT
goto @NPCACT_QuestDairyToday_ExceptSay

[@NPCACT_QuestDairyToday_Case4_New]
#IF
!Checkitem %A2 %D3
#ACT
break
#SAY
Ȳ鿴һûµƷ \\
< /@exit>

#IF
Checkitem %A2 %D3
!Equal A0 "PreEnd"
#ACT
Take %A2 %D3
goto @NPCACT_QuestDairyToday_NewSay
#ELSESAY
˺ﲻʲôæ \\
< /@exit>

[@NPCACT_QuestDairyToday_Case3]
#ACT
Mov D5 %D2
Inc D5 1
#IF
!Checkitem %A1 %D5
Checkitem %A1 %D2
#ELSEACT
break
#ELSESAY
Ҫ<$OUTPUT(D2)><$OUTPUT(A1)>ܼ㴿ȡܶҲ~~ \\
< /@exit>

#IF
!Checkitem %A1 %D5
Checkitem %A1 %D2
Checkduraeva %A1 %D3
#ACT
take %A1 %D2
goto @NPCACT_QuestDairyToday_Result
#ELSEACT
goto @NPCACT_QuestDairyToday_ExceptSay

[@NPCACT_QuestDairyToday_Case2]
#IF
Equal A0 "PreEnd"
#ACT
goto @NPCACT_QuestDairyToday_Case2_Step0
#ELSEACT
goto @NPCACT_QuestDairyToday_ExceptSay

[@NPCACT_QuestDairyToday_Case2_Step0]
#IF
checkitem %A2 %D3
#ACT
take %A2 %D3
goto @NPCACT_QuestDairyToday_Result
#ELSEACT
goto @NPCACT_QuestDairyToday_ExceptSay

[@NPCACT_QuestDairyToday_Case1]
#IF
Equal A0 "PreEnd"
#ACT
goto @NPCACT_QuestDairyToday_Result
#ELSEACT
goto @NPCACT_QuestDairyToday_ExceptSay

[@NPCACT_QuestDairyToday_Case0]
#IF
Equal A1 "Money"
CheckGold %D2
#ACT
take  %D2
goto @NPCACT_QuestDairyToday_Case0_Step1
break

#IF
!Equal A1 "Money"
checkitem %A1 %D2
#ACT
take %A1 %D2
goto @NPCACT_QuestDairyToday_Case0_Step1
break

#IF
#ACT
goto @NPCACT_QuestDairyToday_ExceptSay
break

[@NPCACT_QuestDairyToday_Case0_Step1]
#IF
Equal A2 "NULL"
#ACT
goto @NPCACT_QuestDairyToday_Result
break

#IF
Checkitem %A2 %D3
#ACT
take %A2 %D3
goto @NPCACT_QuestDairyToday_Case0_Step2
break

#IF
Equal A1 "Money"
!Equal A2 "NULL"
#ACT
Give  %D2
goto @NPCACT_QuestDairyToday_ExceptSay
break

#IF
!Equal A1 "Money"
!Equal A2 "NULL"
#ACT
Give %A1 %D2
goto @NPCACT_QuestDairyToday_ExceptSay
break

[@NPCACT_QuestDairyToday_Case0_Step2]
#IF
Equal A3 "NULL"
#ACT
goto @NPCACT_QuestDairyToday_Result
break

#IF
checkitem %A3 %D4
#ACT
take %A3 %D4
goto @NPCACT_QuestDairyToday_Result
break

#IF
Equal A1 "Money"
!Equal A3 "NULL"
#ACT
Give  %D2
give %A2 %D3
goto @NPCACT_QuestDairyToday_ExceptSay
break

#IF
!Equal A1 "Money"
!Equal A3 "NULL"
#ACT
give %A1 %D2
give %A2 %D3
goto @NPCACT_QuestDairyToday_ExceptSay
break

[@NPCACT_QuestDairyToday_ExceptSay]
#ACT
FormatStr "FLD_TQIDX=%s" %D0
ReadStringSql "TBL_DairyQuestSet" %A9 "FLD_TQNPCContent2" [@NPCACT_ExceptSayDB]

[@NPCACT_ExceptSayDB]
#ACT
Mov A5 %ARG(1)
#SAY
<$OUTPUT(A5)> \
<ִ/@exit>

[@NPCACT_QuestDairyToday_NewSay]
#ACT
FormatStr "FLD_USERNAME='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Step='PreEnd'"
FormatStr "FLD_TQIDX=%s" %D0
ReadStringSql "TBL_DairyQuestSet" %A9 "FLD_TQNPCContent4" [@NPCACT_QuestDairyTodayNewSayDB]

[@NPCACT_QuestDairyTodayNewSayDB]
#ACT
Mov A5 %ARG(1)
#SAY
<$OUTPUT(A5)> \\
< /@exit>

[@NPCACT_QuestDairyToday_Result]
#ACT
goto @NPC_QuestDairyToday_Result

[@NPC_QuestDairyToday_Result]
#IF
#ACT
FormatStr "FLD_USERNAME='%s'" %USERNAME
ReadValueSql "TBL_DairyQuestUser" %A9 "FLD_QuestIdx" [@ACT_QuestDairyToday_Set_Reword]

[@ACT_QuestDairyToday_Set_Reword()]
#ACT
mov D0 %ARG(1)	;;FLD_QuestIdx
FormatStr "FLD_TQIdx='%s'" %D0
ReadValueSql "TBL_DairyQuestSet" %A9 "FLD_TQREword1,FLD_TQREword1Amount,FLD_TQREword2,FLD_TQREword2Amount,FLD_TQREword3,FLD_TQREword3Amount" [@ACT_QuestDairyToday_Set2_Reword]


[@ACT_QuestDairyToday_Set2_Reword()]
#IF
#ACT
mov A4 %ARG(1)
mov D9 %ARG(2)
mov A5 %ARG(3)
mov D8 %ARG(4)
mov A6 %ARG(5)
mov D7 %ARG(6)

formatstr "<%s:%s/@GETREWORD(1)>"  %A4,%D9
mov A0 %A9

formatstr "<%s:%s/@GETREWORD(2)>"  %A5,%D8
mov A1 %A9

formatstr "<%s:%s/@GETREWORD(3)>"  %A6,%D7
mov A2 %A9


#SAY
ѡҪÿ:\
1.<$OUTPUT(A0)></@GETREWORD(1)>\ 
2.<$OUTPUT(A1)></@GETREWORD(2)>\
3.<$OUTPUT(A2)></@GETREWORD(3)>\

[@GETREWORD()]
#IF
#ACT
mov D9 %ARG(1)

#IF
EQUAL D9 1	;;D9ֵ
#ACT
FormatStr "FLD_TQIDX=%s" %D0
ReadValueSql "TBL_DairyQuestSet" %A9 "FLD_TQReword1,FLD_TQReword1Amount,FLD_TQFame" [@NPCReword_QuestDairyToday_Result_Next]
break

#IF
EQUAL D9 2
#ACT
FormatStr "FLD_TQIDX=%s" %D0
ReadValueSql "TBL_DairyQuestSet" %A9 "FLD_TQReword2,FLD_TQReword2Amount,FLD_TQFame" [@NPCReword_QuestDairyToday_Result_Next]
break

#IF
EQUAL D9 3
#ACT
FormatStr "FLD_TQIDX=%s" %D0
ReadValueSql "TBL_DairyQuestSet" %A9 "FLD_TQReword3,FLD_TQReword3Amount,FLD_TQFame" [@NPCReword_QuestDairyToday_Result_Next]
break

[@NPCReword_QuestDairyToday_Result_Next()]
#IF
#SAY
Ժ\\
#ACT
mov D6 %P9
mov A4 %ARG(1)
mov D4 %ARG(2)
mov D5 %ARG(3)
FormatStr "FLD_TQIDX=%s" %D0
ReadStringSql "TBL_DairyQuestSet" %A9 "FLD_TQNPCContent3" [@NPCReword_QuestDairyToday_Result_Next1]
break

[@NPCReword_QuestDairyToday_Result_Next1]
#ACT
Mov A5 %ARG(1)

#IF
Equal A4 "Exp"
#SAY
<$OUTPUT(A5)> \
< /@exit>
#ACT
actcmd GIVEEXPEX %D4
Set [210] 0
Set [409] 1
SysMsg "(ÿ) õ <$OUTPUT(D4)> 㡣"
goto @NPCReword_QuestDairyToday_GiveFame
break

#IF
Equal A4 "Money"
#SAY
<$OUTPUT(A5)> \
< /@exit>
#ACT
Give  %D4
Set [210] 0
Set [409] 1
SysMsg "(ÿ) õ <$OUTPUT(D4)>"
goto @NPCReword_QuestDairyToday_GiveFame
break

#IF
!Equal A4 "Exp"
!Equal A4 "Money"
Large D4 10000
#SAY
<$OUTPUT(A5)> \
< /@exit>
#ACT
goto @NPCSet_QuestDairyToday_Next2_Monster
break

#IF
#SAY
<$OUTPUT(A5)> \
< /@exit>
#ACT
Give %A4 %D4
Set [210] 0
Set [409] 1
goto @NPCReword_QuestDairyToday_GiveFame
break


[@NPCSet_QuestDairyToday_Next2_Monster]
#IF
checkmonrecall
#ACT
actcmd GIVEEXPEX 20000
goto @NPCReword_QuestDairyToday_GiveFame
break

#IF
#SAY
<$OUTPUT(A5)> \
< /@exit>
#ACT
Dec D4 10000
monrecall %A4 %D4 0
Set [210] 0
Set [409] 1
goto @NPCReword_QuestDairyToday_GiveFame
break

[@NPCReword_QuestDairyToday_GiveFame]
#ACT
actcmd setfame + %D5
sysmsg "(ÿ) õ <$OUTPUT(D5)> 㡣"
FormatStr "FLD_USERNAME='%s'" %USERNAME
UpdateValueSql "TBL_DairyQuestUser" %A9 "FLD_Status='End',FLD_Step=''"
}
;;----------------------------vimascript